home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
PROGRAMR
/
UPC12BS1.ZIP
/
MAIL
/
MAILBLIB.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-09-20
|
39KB
|
1,114 lines
/*--------------------------------------------------------------------*/
/* m a i l b l i b . c */
/* */
/* Support routines for UUPC/extended mail user agent */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* Changes Copyright (c) 1989-1993 by Kendra Electronic */
/* Wonderworks. */
/* */
/* All rights reserved except those explicitly granted by */
/* the UUPC/extended license agreement. */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* RCS Information */
/*--------------------------------------------------------------------*/
/*
* $Id: mailblib.c 1.4 1993/09/20 04:41:54 ahd Exp $
*
* Revision history:
* $Log: mailblib.c $
* Revision 1.4 1993/09/20 04:41:54 ahd
* OS/2 2.x support
*
* Revision 1.3 1993/07/31 16:26:01 ahd
* Changes in support of Robert Denny's Windows support
*
*/
/*--------------------------------------------------------------------*/
/* System include files */
/*--------------------------------------------------------------------*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#if defined(_Windows)
#include <windows.h>
#endif
/*--------------------------------------------------------------------*/
/* UUPC/extended include files */
/*--------------------------------------------------------------------*/
#include "lib.h"
#include "address.h"
#include "mail.h"
#include "maillib.h"
#include "mailblib.h"
#include "mailsend.h"
#include "hlib.h"
#include "alias.h"
#include "expath.h"
/*--------------------------------------------------------------------*/
/* Variables global to file */
/*--------------------------------------------------------------------*/
static int *item_list = NULL;
static size_t next_item;
currentfile();
/*--------------------------------------------------------------------*/
/* Internal function prototypes */
/*--------------------------------------------------------------------*/
static boolean SearchUser( char *token , char **input, const int bits);
static boolean SearchSubject( char *token,
char **input,
char *trailing,
const int bits);
/*--------------------------------------------------------------------*/
/* Externally known functions */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* S h o w A l i a s */
/* */
/* Print the expansion of an alias */
/*--------------------------------------------------------------------*/
void ShowAlias( const char *alias)
{
char *fullname = AliasByNick( alias );
static int level = 0;
int column = level * 2;
if ( alias == NULL )
{
printf("Missing operand\n");
return;
}
/*--------------------------------------------------------------------*/
/* Indent nested calls */
/*--------------------------------------------------------------------*/
while(column-- > 0 )
putchar(' ');
/*--------------------------------------------------------------------*/
/* Show the alias, breaking it down recursively if need be */
/*--------------------------------------------------------------------*/
if (fullname == NULL)
{
char user[MAXADDR];
char path[MAXADDR];
char node[MAXADDR];
printf("No alias defined for \"%s\"\n",alias);
column = level * 2 + 2;
while(column-- > 0 )
putchar(' ');
user_at_node(alias, path, node, user);
/* Reduce address to basics */
printf("(%s@%s via %s)\n", user, node, path);
}
else {
printf("%s is aliased to %s\n", alias, fullname);
if (*fullname == '"')
{
if ( debuglevel > 1)
{
char user[MAXADDR];
char path[MAXADDR];
char node[MAXADDR];
ExtractAddress(user,fullname, FALSE);
user_at_node(user,path,node,user);
/* Reduce address to basics */
column = level * 2 + 2;
while(column-- > 0 )
putchar(' ');
printf("(%s@%s via %s)\n", user, node, path);
}
}
else {
char buf[LSIZE];
strcpy( buf, fullname );
fullname = strtok( buf , WHITESPACE "," );
while (fullname != NULL )
{
char *save = strtok( NULL , "");
level++; /* Bump up a level for recursive calls */
ShowAlias(fullname);
level--; /* Restore indent level */
fullname = strtok( save , " ," );
} /* while */
} /* else */
} /* else */
} /* ShowAlias */
/*--------------------------------------------------------------------*/
/* S a v e I t e m */
/* */
/* Save an item in another mailbox */
/*--------------------------------------------------------------------*/
boolean SaveItem( const int item,
const boolean delete,
const copyopt headers,
char *fname,
const ACTION verb)
{
char filename[FILENAME_MAX];
char *s = "?";
FILE *stream;
if (fname == NULL)
fname = "~/mbox";
/*--------------------------------------------------------------------*/
/* Build the file name */
/*--------------------------------------------------------------------*/
switch (*fname)
{
case '=': /* relative to home directory? */
printf("Syntax is obsolete ... use \"~/%s\"", fname + 1 );
mkfilename(filename, E_homedir, ++fname);
break;
case '+': /* Relative to mail directory? */
mkmailbox(filename, ++fname);
break;
default:
case '~': /* Relative to home directory? */
strcpy( filename , fname );
if (expand_path( filename , NULL, E_homedir, E_mailext ) == NULL)
return FALSE;
break;
} /* end switch */
/*--------------------------------------------------------------------*/
/* Announce our action based on the verb */
/*--------------------------------------------------------------------*/
switch( verb )
{
case M_COPY:
s = "Copying";
break;
case M_SAVE:
s = "Saving";
break;
case M_WRITE:
s = "Writing";
break;
} /* switch */
printf("%s item %d to %s\n", s , item + 1, filename );
/*--------------------------------------------------------------------*/
/* Open the mailox to save to */
/*--------------------------------------------------------------------*/
if ((stream = FOPEN(filename, "a",TEX